<template>
  <div class="single">
    <div class="heard">
      <h1>课程AI分析面板</h1>
    </div>
    <div style="padding-bottom: 10px; margin: 30px 25px">
      <div class="class_info">
        <Heard :info="course_info" v-if="course_info"></Heard>
      </div>
      <!-- 课程视频 && 总体评价 -->
      <div class="review_1">
        <div class="video_box">
          <div class="titile">
            <h5>课程视频</h5>
          </div>
          <VideoPlayer :url="dataAll.course_info.video_list[0].play_url" :video-list="dataAll.course_info.video_list" :marker="dataAll.video_info_point" />
        </div>
        <div class="right">
          <div class="evaluate" style="position: relative; height: 306px">
            <div class="titile">
              <h5>总体评价</h5>
            </div>
            <div>
              <div style="background-color: #14638c; width: 10%; padding: 5px 10px; text-align: center; border-radius: 5px; margin: 10px 20px">
                <span style="font-size: 12px">讲授型课堂</span>
              </div>
              <div style="border: 1px dashed #0bc9f9; height: 150px; overflow: hidden; margin: 10px 20px; border-radius: 10px">
                <BarChart :id="'bar1'" style="height: 180px" :barData="allocation_value" />
              </div>
              <div class="text_div" style="position: absolute; bottom: 0; border: 1px solid #1f4b7d">
                <p>{{ allocation_summarize }}</p>
              </div>
            </div>
          </div>
          <!-- 教学行为数据 -->
          <div>
            <teachingBehavior :title="'教学行为数据'" :data="teacher_behavior" />
          </div>
        </div>
      </div>

      <!--重点学情回顾 -->
      <div class="review_2" style="display: block">
        <div class="titile">
          <h5>重点学情回顾</h5>
        </div>
        <div style="display: flex; width: 100%; height: 90%; margin: 20px 0 0 20px">
          <div style="width: 30%; position: relative">
            <!-- :style="{ height: curve_summarize ? '85 %' : '100%' }" -->
            <FlodLine :id="'line1'" :title="'学生专注度曲线'" style="height: 85%" :y-text-data="yFocusData" :is-emote-show="false" :line-data="studentFocusData" :is-legend-show="false" />
            <!-- v-if="curve_summarize" -->
            <div class="text_div" style="position: absolute; bottom: 20px; border: 1px solid #1f4b7d">
              <p>{{ curve_summarize }}</p>
            </div>
          </div>
          <div style="border: 1px solid #196085; width: 1px; height: 95%; margin: 0 20px; background-color: #196085"></div>
          <div style="width: 30%; position: relative; margin-left: 10px">
            <!-- :style="{ height: expression_summarize ? '85 %' : '100%' }" -->
            <FlodLine :id="'line2'" :title="'学生情绪曲线'" style="height: 85%" :is-legend-show="false" :y-text-data="yEmoteData" :line-data="studentEmotionData" />
            <!-- <div v-if="expression_summarize" class="text_div"
              :style="{ height: expression_summarize ? '85 %' : '100%' }" /> -->
            <div class="text_div" v-if="expression_summarize" style="position: absolute; bottom: 20px; border: 1px solid #1f4b7d">
              <p>{{ expression_summarize }}</p>
            </div>
          </div>
          <div style="border: 1px solid #196085; width: 1px; height: 95%; margin: 0 20px; background-color: #196085"></div>
          <div style="width: 32%">
            <learningReview :data="dataAll" />
          </div>
        </div>
      </div>
      <!--重点教情回顾 &&  重要时点回顾 -->
      <div class="review_3">
        <div class="teach_sentiment">
          <div class="titile">
            <h5>重点教情回顾</h5>
            <div style="padding: 15px">
              <evaluate-card :data="teaching_situation" />
            </div>
          </div>
        </div>
        <div class="point_time">
          <div class="titile">
            <h5>重要时点回顾</h5>
          </div>
          <div style="padding: 10px 20px">
            <pointReview @clickViewImg="clickViewImg" v-if="dataAll.important_time_review" :data="dataAll.important_time_review" />
          </div>
        </div>
      </div>
      <!-- 教师反思总结 -->
      <div class="reflect_conclusion">
        <div class="titile">
          <h5>教师反思总结</h5>
        </div>
        <div class="edit_btn" @click="editFeflect">
          <span>{{ editdialog ? "编辑" : "保存" }}</span>
        </div>
        <div style="margin: 20px">
          <el-input type="textarea" :disabled="editdialog" :autosize="{ minRows: 5, maxRows: 7 }" placeholder="请输入内容" v-model="dataAll.reflect_info"> </el-input>
        </div>
      </div>
    </div>
    <el-dialog :title="viewDialogTitle" :visible.sync="dialogVisible" width="550px">
      <div style="padding-bottom: 30px">
        <img :src="viewImgUrl" alt="" style="width: 100%; height: 100%; margin: auto" />
      </div>
    </el-dialog>
  </div>
</template>

<script>
import Heard from "./../../common/ai/heard-info.vue";
import VideoPlayer from "../../ai/components/video-player.vue";
import hjPlayer from "./../../common/hjPlayer";
import * as echarts from "echarts";
import FlodLine from "../../common/echarts/fold-line.vue";
import BarChart from "../../common/echarts/bar-chart.vue";
import evaluateCard from "../../common/ai/evaluate-card.vue";
import teachingBehavior from "../components/teaching-behavior.vue";
import learningReview from "../components/learning-review.vue";
import pointReview from "../components/point-review.vue";

export default {
  components: {
    hjPlayer,
    FlodLine,
    Heard,
    VideoPlayer,
    BarChart,
    evaluateCard,
    teachingBehavior,
    learningReview,
    pointReview
  },
  data() {
    return {
      course_id: this.$route.query.id,
      loading: true, //加载动画
      yEmoteData: ["愤怒", "厌恶", "恐惧", "快乐", "中性", "悲伤", "惊喜"],
      yFocusData: ["未学习", "未听讲", "走神", "中性", "集中", "专注"],
      dataAll: {
        important_time_review: null
      },
      course_info: null,
      teacher_behavior: {
        podium: "0", //讲台时长（秒）
        trajectory: "0", //巡视时长（秒）
        trajectory_times: "0", //巡视次数
        teach_duration: "0", //讲授时长（秒）
        interaction_duration: "0", //互动时长(秒)
        guidance_duration: "0", //指导时长(秒)
        blackboard_duration: "0" //板书时长(秒)
      },
      // 重点教情回顾
      teaching_situation: {
        teaching_rhythm: "暂无",
        dataList: [
          {
            name: "教师讲授占比",
            value: "33.3%"
          },
          {
            name: "师生互动占比",
            value: "33.3%"
          },
          {
            name: "学生学习占比",
            value: "33.3%"
          },
          {
            name: "PPT翻页间隔",
            value: "3.4分钟"
          },
          {
            name: "师生互动频率",
            value: "较高"
          },
          {
            name: "学生练习频率",
            value: "较高"
          }
        ]
      },
      // 学生专注度曲线
      studentFocusData: [
        {
          name: "专注度",
          data: [
            // [14, 1],
            // [15, 2],
            // [16, 3],
            // [17, 4],
            // [18, 5],
            // [19, 2],
            // [20, 0],
            // [21, 1],
            // [22, 2],
            // [23, 3],
            // [24, 3],
            // [25, 4],
            // [26, 5],
            // [27, 3],
            // [28, 4],
            // [29, 3]
          ],
          color: "#61D8D8",
          lineBGColor: "#61d8d8bd"
        }
      ],
      curve_summarize: null,
      // 学生情绪曲线
      studentEmotionData: [
        {
          name: "情绪",
          data: [
            // [14, 1],
            // [15, 2],
            // [16, 3],
            // [17, 4],
            // [18, 5],
            // [19, 6],
            // [20, 0],
            // [21, 1],
            // [22, 2],
            // [23, 3],
            // [24, 3],
            // [25, 4],
            // [26, 5],
            // [27, 6],
            // [28, 4],
            // [29, 3]
          ],
          color: "#3158FF",
          lineBGColor: "#3057f9b0"
        }
      ],
      expression_summarize: null,
      // 课程分配时间图
      allocation_value: null,
      //
      dialogVisible: false,
      viewImgUrl: null,
      viewDialogTitle: null,
      editdialog: true,
      allocation_summarize: null
    };
  },
  mounted() {
    this.init();
  },
  methods: {
    //照片预览
    clickViewImg(e) {
      this.viewImgUrl = e.url;
      this.dialogVisible = true;
      this.viewDialogTitle = e.type == "focus" ? "高专注时段视频截图" : "学生回答问题时段视频截图";
    },
    // 教师反思总结编辑
    editFeflect() {
      if (!this.editdialog) {
        let success = (res) => {
          this.editdialog = true;
          this.$message.success("编辑成功");
        };
        this.$ajax({
          url: "/api/ainew/videoReflect",
          method: "PUT",
          data: {
            course_id: this.course_id,
            reflect_info: this.dataAll.reflect_info
          },
          func: { success: success }
        });
      } else {
        this.editdialog = false;
      }
    },
    init() {
      this.loading = true;

      const success = (res) => {
        this.loading = false;
        let data = res.data;
        this.dataAll = data;
        //课程详情信息
        let dataTime = data.course_info.course_time.split(" ");
        this.course_info = {
          ...this.dataAll.course_info,
          report_name: data.teacher_report.name,
          classData: [
            {
              course_name: data.course_info.course_name,
              class_name: data.course_info.class_name,
              course_data: dataTime[0],
              course_time: dataTime[1] + dataTime[2] + dataTime[3]
            }
          ]
        };

        //教学行为数据
        if (data.teacher_behavior)
          this.teacher_behavior = {
            ...data.teacher_behavior.teaching_trajectory_duration,
            ...data.teacher_behavior.teaching_behavior_duration
          };
        //重点教情回顾
        console.log("重点教情回顾----", data.teaching_situation);
        this.teaching_situation.teaching_rhythm = data.teaching_situation.teaching_rhythm;
        let dataList = [
          {
            name: "教师讲授占比",
            value: data.teaching_situation.teacher_time_rate
          },
          {
            name: "师生互动占比",
            value: data.teaching_situation.interaction_rate
          },
          {
            name: "学生学习占比",
            value: data.teaching_situation.study_rate
          },
          {
            name: "PPT翻页间隔",
            value: data.teaching_situation.flipping_interval
          },
          {
            name: "师生互动频率",
            value: data.teaching_situation.interaction_rate
          },
          {
            name: "学生练习频率",
            value: data.teaching_situation.study_frequency
          }
        ];
        this.teaching_situation.dataList = dataList;
        // 学生情绪-折现图

        this.studentEmotionData.data = data.student_behavior.expression.expression_value;
        this.expression_summarize = data.student_behavior.expression.expression_summarize;
        console.log("学生情绪-折现图---", this.studentEmotionData.data);
        // 学生专注度曲线-折线图
        console.log("学生专注度曲线-折线图---", data.student_behavior.show.curve_value);
        this.studentFocusData.data = data.student_behavior.show.curve_value;
        this.expression_summarize = data.student_behavior.show.curve_summarize;

        // 课程分配时间图
        this.allocation_value = data.time_allocation.allocation_value;
        this.allocation_summarize = data.time_allocation.allocation_summarize;
      };

      this.$ajax({
        url: "api/ainew/courseInfo",
        method: "get",
        params: {
          // 课程id
          course_id: this.course_id
        },
        func: { success: success }
      });
    }
  }
};
</script>
<style scoped></style>
<style lang="scss">
/**** */
.single {
  background-color: #122a54;
  width: 100%;
  height: 100%;
  color: #fff;
  overflow: hidden;

  .el-dialog__body {
    background-color: #122a54;
  }

  .el-dialog__header {
    background-color: #21469a;
    padding: 10px 15px;
  }

  .el-dialog__title {
    color: #fff;
    font-size: 16px;
  }

  .el-textarea__inner,
  .el-textarea.is-disabled .el-textarea__inner {
    background-color: #1e5fc99c;
    border: none;
    color: #fff;
  }

  .heard {
    height: 74px;
    background: url("../../../assets/images/teach_ai/top.png") center center / 100% 100% no-repeat;
  }

  h1 {
    font-size: 32px;
    font-weight: bold;
    line-height: 48px;
    text-align: center;
    font-family: SourceHanSansCN, SourceHanSansCN;
  }

  h3 {
    font-size: 22px;
    line-height: 33px;
    text-align: left;
    font-family: SourceHanSansCN, SourceHanSansCN;
  }

  h5 {
    font-family: PingFangSC, PingFang SC;
    font-weight: 500;
    font-size: 20px;
    color: #ffffff;
    line-height: 33px;
    text-align: left;
  }

  .class_info {
    display: flex;
    justify-content: space-between;
    // height: 132px;
    // margin: 30px 30px 10px 30px;
  }

  .review_1 {
    display: flex;
    justify-content: space-between;
    height: 580px;
    margin: 10px 0;

    .titile {
      height: 35px;
      padding-left: 30px;
      background: url("../../../assets/images/teach_ai/title_bg_931.png") center center / 100% 100% no-repeat;
    }

    .video_box {
      width: 100%;
      background-color: #1d345c;
      margin: 8px;
    }

    .right {
      width: 100%;
      margin: 5px;
    }

    .evaluate {
      background-color: #1d345c;

      .da_value {
        font-family: PingFangSC, PingFang SC;
        font-size: 24px;
        color: #ffc770;
        line-height: 34px;
        padding: 10px 0;
      }
    }
  }

  .review_2 {
    display: flex;
    justify-content: space-between;
    height: 570px;
    margin: 10px 0;
    background-color: #1d345c;

    .titile {
      width: 100%;
      height: 35px;
      padding-left: 30px;
      background: url("../../../assets/images/teach_ai/title_bg_1873.png") center center / 100% 100% no-repeat;
    }
  }

  .review_3 {
    display: flex;
    justify-content: space-between;
    height: 250px;
    margin: 10px 0;

    .teach_sentiment {
      width: 40%;
      background-color: #1d345c;
      margin: 8px;

      .titile {
        height: 35px;
        padding-left: 30px;
        background: url("../../../assets/images/teach_ai/title_bg_721.png") center center / 100% 100% no-repeat;
      }
    }

    .point_time {
      width: 60%;
      margin: 8px;
      background-color: #1d345c;

      .titile {
        height: 35px;
        padding-left: 30px;
        background: url("../../../assets/images/teach_ai/title_bg_1126.png") center center / 100% 100% no-repeat;
      }
    }
  }

  .reflect_conclusion {
    position: relative;
    margin: 10px 0;
    height: 240px;
    background-color: #1d345c;

    .titile {
      height: 35px;
      padding-left: 30px;
      background: url("../../../assets/images/teach_ai/title_bg_1873.png") center center / 100% 100% no-repeat;
    }

    p {
      line-height: 26px;
      font-size: 14px;
    }

    .edit_btn {
      position: absolute;
      right: 10px;
      top: 5px;
      height: 25px;
      width: 50px;
      text-align: center;
      cursor: pointer;
      line-height: 25px;
      background: url("../../../assets/images/teach_ai/edit_btn_bg.png") center center / 100% 100% no-repeat;
    }
  }
}

.info_3 {
  height: 134px;
  width: 100%;
  margin: 5px;
  background: url("../../../assets/images/teach_ai/kuang_137.png") center center / 100% 100% no-repeat;
}

.info_4 {
  height: 90px;
  width: 100%;
  margin: 5px;
  background: url("../../../assets/images/teach_ai/kuang_210.png") center center / 100% 100% no-repeat;
}

.value_bule {
  color: #66ffff;
  font-size: 24px;
  line-height: 34px;
}

.text_div {
  background-color: #13366e;
  padding: 15px;
  border-radius: 10px;

  p {
    line-height: 18px;
  }
}

.grid_3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: auto auto;
  gap: 30px;
}

.sen_info1 {
  text-align: center;

  height: 155px;
  width: 100%;
  margin: 5px;
  background: url("../../../assets/images/teach_ai/kuang_236.png") center center / 100% 100% no-repeat;
}

.sen_info {
  height: 70px;
  text-align: center;
  width: 100%;
  margin: 5px;
  background: url("../../../assets/images/teach_ai/kuang_137.png") center center / 100% 100% no-repeat;
}

.p_absolute {
  width: 100%;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

/**end */
</style>
